package com.lsl.abstract_factory.execute;

import com.lsl.abstract_factory.factory.Factory;
import com.lsl.abstract_factory.factory.Link;
import com.lsl.abstract_factory.factory.Page;
import com.lsl.abstract_factory.factory.Tray;

import java.util.ArrayList;

/**
 * @author Zed
 * @description
 * @date 2022/11/27 22:16
 */
public class Main {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("com.lsl.abstractFactory.listfactory.ListFactory");
        list.add("com.lsl.abstractFactory.tablefactory.TableFactory");
        for (String className : list) {
            Factory factory = Factory.getFactory(className);
            Link peopeo = factory.createLink(" 人民日报 ", "http://www.people.com.cn/");
            Link gmw = factory.createLink(" 光明日报 ", "http://www.gmw.cn/");

            Link usYahoo = factory.createLink(" Yahoo ", "http://www.yahoo.com/");
            Link jpYahoo = factory.createLink(" Yahoo!Japen ", "http://www.yahoo.co.jp/");

            Link baidu = factory.createLink(" 百度 ", "http://www.baidu.com");
            Link google = factory.createLink(" Google ", "http://www.google.com");


            Tray trayNews = factory.createTray(" 日报 ");
            trayNews.add(peopeo);
            trayNews.add(gmw);

            Tray trayYahoo = factory.createTray("Yahoo!");
            trayYahoo.add(usYahoo);
            trayYahoo.add(jpYahoo);


            Tray traySearch = factory.createTray(" 搜索引擎 ");
            traySearch.add(baidu);
            traySearch.add(google);
            traySearch.add(trayYahoo);

            Page page = factory.createPage("LinkPage", "刘胜利");
            page.add(trayNews);
            page.add(traySearch);
            page.outPut();
        }
    }
}
